# Contributor: Leo <thinkabit.ukim@gmail.com>
# Contributor: Antoni Aloy <aaloytorrens@gmail.com>
# Contributor: Diego Queiroz <diego.queiroz@gmail.com>
# Maintainer: Diego Queiroz <diego.queiroz@gmail.com>
pkgname=zbar
pkgver=0.23.92
pkgrel=2
pkgdesc="Port of ZBAR BAR CODE READER"
url="https://zbar.sourceforge.net/"
arch="all"
license="LGPL-2.0-or-later"
depends="py3-gobject3"
makedepends="imagemagick-dev gtk+3.0-dev qt5-qtx11extras-dev lcms2-dev
	automake autoconf libtool xmlto docbook-xsl libxv-dev python3-dev
	gettext-dev gobject-introspection-dev"
subpackages="
	$pkgname-dev
	$pkgname-doc
	lib$pkgname:zbarlibs
	lib${pkgname}qt:qtlibs
	lib${pkgname}gtk:gtklibs
	py3-${pkgname}:py
	"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/mchehab/zbar/archive/$pkgver.tar.gz
	py3.11.patch
	"

prepare() {
	default_prepare
	autoreconf -fi
}

build() {
	LDFLAGS="$LDFLAGS -lintl" \
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--disable-video \
		--with-python=python3 \
		--with-gtk=gtk3 \
		--with-gir \
		--with-dbusconfdir=/usr/share
	make
}

package() {
	make DESTDIR="$pkgdir" install
	rm -rf "$pkgdir"/usr/lib/*.a
}

zbarlibs() {
	depends=""
	pkgdesc="$pkgdesc (library)"
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/libzbar.so.* "$subpkgdir"/usr/lib
}

qtlibs() {
	depends=""
	pkgdesc="$pkgdesc (Qt5 library)"
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/libzbarqt.so.* "$subpkgdir"/usr/lib
}

gtklibs() {
	depends=""
	pkgdesc="$pkgdesc (Gtk+3 library)"
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/libzbargtk.so.* "$subpkgdir"/usr/lib
}

py() {
	depends=""
	pkgdesc="python3 bindings for ZBar"
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/python3* "$subpkgdir"/usr/lib
}

sha512sums="
cae47fb199173fc1c052984865ca0e6aeab330bd6d77506a0937994d459deb4419a3e54e2dcd2e9830ffb8acf14f29e22e0a6becc9e4cfe19b07dad1babe9513  zbar-0.23.92.tar.gz
caa6d4a845887ebddc214a9cf4b6265914112a12e6ddc4c2e44f823b151ddaf242c5096584d273b3c4fc227df2633cbc0b5ebf5847c6d587ed5884da110f07d7  py3.11.patch
"
